package com.xxd.rpt2.vo;

import org.springframework.http.HttpStatus;

import java.io.Serializable;

public class ResultModel<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String SUCCESS = HttpStatus.OK.name();
    public static final Integer SUCCESS_CODE = HttpStatus.OK.value();

    private boolean result  ;
    private Integer code = SUCCESS_CODE;
    private String message;
    private T data;

    public ResultModel(){
        this.code = SUCCESS_CODE;
        this.message = SUCCESS;
    }

    public ResultModel(int code,String message, T data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResultModel(HttpStatus data,String msg){
        this.code = data.value();
        this.message = data.name() +":"+msg;
    }

    public ResultModel(T data ){
        this.code = SUCCESS_CODE;
        this.message = SUCCESS;
        this.data = data;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


}
